package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.EmployeePageQueryDTO;
import com.sky.entity.Employee;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface EmployeeMapper {

    /**
     * 根据用户名查询员工
     *
     * @param username 用户名
     * @return 员工信息
     */
    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);

    /**
     * 新增员工
     *
     * @param employee 员工实体
     */
    @AutoFill(OperationType.INSERT)
    @Insert("INSERT INTO employee(name, username, password, phone, sex, id_number, create_time, update_time, create_user, update_user) VALUES (#{name}, #{username}, #{password}, #{phone}, #{sex}, #{idNumber}, #{createTime}, #{updateTime}, #{createUser}, #{updateUser})")
    void inset(Employee employee);

    /**
     * 分页查询员工
     * @param employeePageQueryDTO 员工分页查询条件
     * @return 员工分页查询结果
     */
    Page<Employee> selectPage(EmployeePageQueryDTO employeePageQueryDTO);

    /**
     * 根据 ID 查询员工
     *
     * @param id 员工主键
     * @return 员工详情
     */
    Employee selectById(Long id);

    /**
     * 更新员工状态
     *
     * @param employee 员工信息
     */
    @AutoFill(OperationType.UPDATE)
    void updateStatus(Employee employee);

    /**
     * 更新员工信息
     *
     * @param employee 员工实体
     */
    @AutoFill(OperationType.UPDATE)
    void update(Employee employee);
}
